package com.chao.rabbit.receiver;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author : Rookie
 * @description :
 * @date : 2022/10/30
 */
@Component
public class RouteConsumer {

    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue, //创建临时队列
                exchange = @Exchange(value = "directs"),
                key = {"info","error","debug"}) //指定交换机名称和类型
    })
    public void receive1(String message) {
        System.out.println("收到路由类型消息1" + message);
    }

    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue, //创建临时队列
                    exchange = @Exchange(value = "directs"),
                    key = {"error"}) //指定交换机名称和类型
    })
    public void receive2(String message) {
        System.out.println("收到路由类型消息2" + message);
    }
}
